package com.ruoyi.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.business.domain.BusSpjgFlow;
import com.ruoyi.business.service.IBusSpjgFlowService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 流量统计Controller
 * 
 * @author ruoyi
 * @date 2023-07-21
 */
@Api(tags = "食品加工-流量统计")
@RestController
@RequestMapping("/spjg/flow")
public class BusSpjgFlowController extends BaseController
{
    @Autowired
    private IBusSpjgFlowService busSpjgFlowService;

    /**
     * 查询流量统计列表
     */
    @ApiOperation("列表")
    @GetMapping("/list")
    public TableDataInfo list(BusSpjgFlow busSpjgFlow)
    {
        startPage();
        List<BusSpjgFlow> list = busSpjgFlowService.selectBusSpjgFlowList(busSpjgFlow);
        return getDataTable(list);
    }

    /**
     * 导出流量统计列表
     */
    @PreAuthorize("@ss.hasPermi('spjg:flow:export')")
    @Log(title = "流量统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BusSpjgFlow busSpjgFlow)
    {
        List<BusSpjgFlow> list = busSpjgFlowService.selectBusSpjgFlowList(busSpjgFlow);
        ExcelUtil<BusSpjgFlow> util = new ExcelUtil<BusSpjgFlow>(BusSpjgFlow.class);
        util.exportExcel(response, list, "流量统计数据");
    }

    /**
     * 获取流量统计详细信息
     */
    @PreAuthorize("@ss.hasPermi('spjg:flow:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(busSpjgFlowService.selectBusSpjgFlowById(id));
    }

    /**
     * 新增流量统计
     */
    @PreAuthorize("@ss.hasPermi('spjg:flow:add')")
    @Log(title = "流量统计", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BusSpjgFlow busSpjgFlow)
    {
        return toAjax(busSpjgFlowService.insertBusSpjgFlow(busSpjgFlow));
    }

    /**
     * 修改流量统计
     */
    @PreAuthorize("@ss.hasPermi('spjg:flow:edit')")
    @Log(title = "流量统计", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BusSpjgFlow busSpjgFlow)
    {
        return toAjax(busSpjgFlowService.updateBusSpjgFlow(busSpjgFlow));
    }

    /**
     * 删除流量统计
     */
    @PreAuthorize("@ss.hasPermi('spjg:flow:remove')")
    @Log(title = "流量统计", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(busSpjgFlowService.deleteBusSpjgFlowByIds(ids));
    }
}
